<!--
新闻中心修改
 add by yyp 2019-04-10
-->
<template lang="pug">
  kalix-dialog.user-add(bizKey="CategoryName" ref="kalixBizDialog"
  v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot" style=" width:60%;margin:auto;")
      el-form-item(label="消息类别名称" prop="name" label-width="120px" v-bind:rules="rules.name")
        el-input(v-model="formModel.name" style="width:80%")

</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {CategoryNameURL} from '../../config.toml'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  import KalixImgUpload from '../../../../../components/corelib/components/common/imgUpload'
  export default {
    name: 'categorynameEdit',
    components: {
      KalixSelect,
      KalixClansmanUpload,
      KalixImgUpload
    },
    data() {
      return {
        action: baseURL + '/camel/rest/upload',
        formModel: Object.assign({}, FormModel),
        rules: {
          name: [{required: true, message: '请输入修改的名称', trigger: 'blur'}]
        },
        targetURL: CategoryNameURL,
        labelWidth: '110px'
      }
    },
    methods: {
      ImgDel(imgUrl) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          let arrImg = this.formModel.imgUrl.split(',')
          console.log('arrImg++++++++++++++', arrImg)
          let idx = arrImg.indexOf(imgUrl)
          arrImg.splice(idx, 1)
          this.formModel.imgUrl = arrImg.join(',')
          console.log('this.formModel.imgUrl++++++++++++++', this.formModel.imgUrl)
          // this.filePathArr = arrImg
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)

        this.formModel.newUrl = filePath
        this.formModel.imgName = fileName
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 50%
    margin auto
    .radio
      margin-left 150px
      margin-bottom 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
  .img-margin
    margin-left 150px
</style>
